using System;
using System.Drawing.Drawing2D;
using UnityEngine;

namespace player
{
    public enum StateCode
    {
        Idle,
        Run,
        Jump,
        Fall,
        WallJump,
        WallSlide,
        Dash,
        Attack
    }

    public class State : EntityState
    {
        public StateCode state;

        protected Player player;

        // ========================================================================

        public void Init(Animator animator, Player player)
        {
            this.animator = animator;
            this.player = player;
        }

        // ========================================================================

        public override void LateProcess()
        {
            base.LateProcess();

            if (player.input.GamePlay.Dash.WasPressedThisFrame())
            {
                DashState dashState = (DashState)player.GetState(StateCode.Dash);
                if (!dashState.Check()) return;

                dashState.direction = Math.Sign(player.moveInput.x);
                if (dashState.direction == 0) dashState.direction = player.FacingDirection();
                player.ChangeState(dashState);
            }
        }
    }
}

